package com.tianyang.yukuaifu.business.trade.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.business.trade.bean.WithdrawRecordOutput;
import com.tianyang.yukuaifu.utils.DateUtils;
import com.tianyang.yukuaifu.utils.VerifyUtil;

import java.util.ArrayList;

/**
 * Description：提现记录
 * Created by xyj on 2024/3/11
 */
public class WithdrawRecordAdapter extends BaseQuickAdapter<WithdrawRecordOutput, BaseViewHolder> {

    public WithdrawRecordAdapter() {
        super(R.layout.item_withdraw_record, new ArrayList<>());
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, WithdrawRecordOutput item) {
        if (item != null) {
            helper.setText(R.id.outTradeIdTv, VerifyUtil.checkString(item.getOutTradeId()))
                    .setText(R.id.timeTv, "时间：" + DateUtils.formatTime(item.getCreateTime()))
                    .setText(R.id.amountTv, VerifyUtil.decimalFormat(item.getAmount()));
            TextView stateTv = helper.getView(R.id.stateTv);
            switch (item.getState()) {
                case 0:
                    stateTv.setText("成功");
                    stateTv.setTextColor(ContextCompat.getColor(mContext, R.color.black));
                    break;
                case 3:
                    stateTv.setText("处理中");
                    stateTv.setTextColor(ContextCompat.getColor(mContext, R.color.color_base));
                    break;
                case 1:
                    stateTv.setText("失败");
                    stateTv.setTextColor(ContextCompat.getColor(mContext, R.color.color_base));
                    break;
                case 7:
                    stateTv.setText("待审核");
                    stateTv.setTextColor(ContextCompat.getColor(mContext, R.color.color_base));
                    break;
            }
        }
    }
}
